package com.gitee.ywj1352.sharing.db;


import java.util.HashSet;
import java.util.Set;

/**
 * @see DynamicDataSource
 * work for DynamicDataSource
 */
public class DataSourceContextHolder {

    private static final ThreadLocal<String>  holder = new ThreadLocal<>();

    private static Set<Object> dataSourceKeys = new HashSet<>();



    public static String getDataSource(){
       return holder.get();
    }
    public static void setDataSource(String nameKey){
        if (dataSourceKeys.contains(nameKey))
            holder.set(nameKey);
    }


    public static void addDataSourceKeys(Set<Object> keySet) {
        dataSourceKeys.addAll(keySet);
    }
}
